$dir="/data2/bsi/RandD/Arraybased_RND/tcga_genotyping";
$sdrf_dir="$dir/SRDF";
open(BUFF,"$dir/AFFY/files");
while(<BUFF>)
{
	chomp($_);
	#print $_."\n";
	$sys="mkdir $sdrf_dir/$_";
	#print $sys."\n";
	#system($sys);
	$sys="mv $dir/AFFY/$_/*.sdrf.txt $sdrf_dir/$_";
	#print $sys."\n";
	#system($sys);
	$sys ="perl ./scripts/perl_create_sdrf.pl -d $sdrf_dir/$_ -o  $sdrf_dir/$_.sdrf";
	#print $sys."\n";
	#system($sys);
	if(!(-e "/data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/NORMAL/fwdStrandResults_all_merged_removeddup_normal_build36.tped"))
	{
		$fil="config_exp_$_";
		open(CONFIG,">$dir/configfiles/$fil") or die "not able to write\n";	
		#system("mkdir $dir/results/$_");
		print CONFIG "OUTPUT_FOLDER=$dir/results/$_\n";
		print CONFIG "TEMP_FOLDER=/data4/bsi/BORA/TCGA/temp\n";
		print CONFIG "ERROR_FILE=sample.error\n";
		print CONFIG "QC_FILE=sample.qc\n";
		print CONFIG "AFFY6=$dir/AFFY/$_\n";
		print CONFIG "ILLREAL=NA\n";
		print CONFIG "ILLREAL_AT=NA\n";
		print CONFIG "ILLALLELE=NA\n";
		print CONFIG "ILLALLELE_AT=NA\n";
		print CONFIG "SDRF=$dir/SRDF/$_.sdrf\n";
		print CONFIG "ANNOT_ILL_ALLELE=NA\n";
		print CONFIG "ROUND=$_\n";
		open(SAMPLE,">$dir/configfiles/submit_$_.csh") or die "not able to write\n";
		print SAMPLE '#! /bin/bash'."\n";
		print SAMPLE '#$ -q 4-days'."\n";
		print SAMPLE '#$ -l h_vmem=20G'."\n";
		print SAMPLE '#$ -M prodduturi.naresh@mayo.edu'."\n";
		print SAMPLE '#$ -m abe'."\n";
		print SAMPLE '#$ -V'."\n";
		print SAMPLE '#$ -cwd'."\n";
		print SAMPLE "#perl /data4/bsi/bioinf_int/s106381.borawork/naresh_scripts/SVN/tcga_dataprocess_boraworkflow/bin/mainscript_tcgadataprocess.pl -config $dir/configfiles/$fil\n";
		#$sys="qsub $dir/configfiles/submit_$_.csh";
		#print "$sys\n";		
		#system($sys);
		print SAMPLE "perl /data4/bsi/bioinf_int/s106381.borawork/naresh_scripts/SVN/genotyping_QC_FWD/perl_upgrade_build36_files.pl /data4/bsi/RandD/Workflow/genotyping_1000genome_impute/complete1KGSNPS_split/ /data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/NORMAL/fwdStrandResults_all_merged_removeddup_normal.tped /data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/NORMAL/fwdStrandResults_all_merged_removeddup_normal_build37.tped /data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/NORMAL/fwdStrandResults_all_merged_removeddup_normal_build36.tped\n";
		print SAMPLE "perl /data4/bsi/bioinf_int/s106381.borawork/naresh_scripts/SVN/genotyping_QC_FWD/perl_upgrade_build36_files.pl /data4/bsi/RandD/Workflow/genotyping_1000genome_impute/complete1KGSNPS_split/ /data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/TUMOR/fwdStrandResults_all_merged_removeddup_tumor.tped /data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/TUMOR/fwdStrandResults_all_merged_removeddup_tumor_build37.tped /data2/bsi/RandD/Arraybased_RND/tcga_genotyping/results/$_/TUMOR/fwdStrandResults_all_merged_removeddup_tumor_build36.tped\n";
		$sys="qsub $dir/configfiles/submit_$_.csh";
		print "$sys\n";
		system($sys); 
	}
}
